home *** CD-ROM | disk | FTP | other *** search
- Path: news.logicon.com!newsmaster@klee
- From: kkolda@logicon.com (Kenneth D. Kolda)
- Newsgroups: comp.lang.c++
- Subject: Re: static members of a class template
- Date: 26 Mar 1996 17:35:56 GMT
- Organization: Logicon Operating Systems
- Message-ID: <4j99ts$num@piper.logicon.com>
- References: <315781CB.2DD1@digex.net>
- NNTP-Posting-Host: 137.51.122.161
- Mime-Version: 1.0
- X-Newsreader: WinVN 0.99.2
-
- In article <315781CB.2DD1@digex.net>, yami@digex.net says...
- >
- >Hi,
- >
- >How would you go about declaring a static member of a class template?
- >Example:
- >
- >template<class kind>
- >class simple {
- > private:
- > static kind someVar;
- >};
- >
- >simple<kind> kind simple::someVar;
- >
- >
- >This seems to follow the general pattern for defining and declaring a
- >static member, but it results in a syntax error. What's the problem?
- >
- >Thanks in advance for any advice!
- >
- >-Steve-
-
-
- I think what you want is as follows:
-
- template simple<class kind> kind simple<kind>::someVar;
-
- where you could also add initialization info if desired. You can then
- override this default initialization, for example, for simple<int> with:
-
- int simple<int>::someVar = 2;
-
-
- Ken
-
-
-
-
-
-
-
-
-
-
-
-
-